/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package EA_Model.IEC61970.ControlArea.impl;

import EA_Model.IEC61970.ControlArea.ControlArea;
import EA_Model.IEC61970.ControlArea.ControlAreaPackage;
import EA_Model.IEC61970.ControlArea.ControlAreaTypeKind;

import EA_Model.IEC61970.Core.impl.PowerSystemResourceImpl;

import EA_Model.IEC61970.Domain.ActivePower;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Control Area</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link EA_Model.IEC61970.ControlArea.impl.ControlAreaImpl#getNetInterchange <em>Net Interchange</em>}</li>
 *   <li>{@link EA_Model.IEC61970.ControlArea.impl.ControlAreaImpl#getPTolerance <em>PTolerance</em>}</li>
 *   <li>{@link EA_Model.IEC61970.ControlArea.impl.ControlAreaImpl#getType <em>Type</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ControlAreaImpl extends PowerSystemResourceImpl implements ControlArea {
	/**
	 * The cached value of the '{@link #getNetInterchange() <em>Net Interchange</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNetInterchange()
	 * @generated
	 * @ordered
	 */
	protected ActivePower netInterchange;

	/**
	 * The cached value of the '{@link #getPTolerance() <em>PTolerance</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPTolerance()
	 * @generated
	 * @ordered
	 */
	protected ActivePower pTolerance;

	/**
	 * The default value of the '{@link #getType() <em>Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected static final ControlAreaTypeKind TYPE_EDEFAULT = ControlAreaTypeKind.AGC;

	/**
	 * The cached value of the '{@link #getType() <em>Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected ControlAreaTypeKind type = TYPE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ControlAreaImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ControlAreaPackage.Literals.CONTROL_AREA;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ActivePower getNetInterchange() {
		if (netInterchange != null && netInterchange.eIsProxy()) {
			InternalEObject oldNetInterchange = (InternalEObject)netInterchange;
			netInterchange = (ActivePower)eResolveProxy(oldNetInterchange);
			if (netInterchange != oldNetInterchange) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ControlAreaPackage.CONTROL_AREA__NET_INTERCHANGE, oldNetInterchange, netInterchange));
			}
		}
		return netInterchange;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ActivePower basicGetNetInterchange() {
		return netInterchange;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNetInterchange(ActivePower newNetInterchange) {
		ActivePower oldNetInterchange = netInterchange;
		netInterchange = newNetInterchange;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ControlAreaPackage.CONTROL_AREA__NET_INTERCHANGE, oldNetInterchange, netInterchange));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ActivePower getPTolerance() {
		if (pTolerance != null && pTolerance.eIsProxy()) {
			InternalEObject oldPTolerance = (InternalEObject)pTolerance;
			pTolerance = (ActivePower)eResolveProxy(oldPTolerance);
			if (pTolerance != oldPTolerance) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ControlAreaPackage.CONTROL_AREA__PTOLERANCE, oldPTolerance, pTolerance));
			}
		}
		return pTolerance;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ActivePower basicGetPTolerance() {
		return pTolerance;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPTolerance(ActivePower newPTolerance) {
		ActivePower oldPTolerance = pTolerance;
		pTolerance = newPTolerance;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ControlAreaPackage.CONTROL_AREA__PTOLERANCE, oldPTolerance, pTolerance));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ControlAreaTypeKind getType() {
		return type;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setType(ControlAreaTypeKind newType) {
		ControlAreaTypeKind oldType = type;
		type = newType == null ? TYPE_EDEFAULT : newType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ControlAreaPackage.CONTROL_AREA__TYPE, oldType, type));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ControlAreaPackage.CONTROL_AREA__NET_INTERCHANGE:
				if (resolve) return getNetInterchange();
				return basicGetNetInterchange();
			case ControlAreaPackage.CONTROL_AREA__PTOLERANCE:
				if (resolve) return getPTolerance();
				return basicGetPTolerance();
			case ControlAreaPackage.CONTROL_AREA__TYPE:
				return getType();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ControlAreaPackage.CONTROL_AREA__NET_INTERCHANGE:
				setNetInterchange((ActivePower)newValue);
				return;
			case ControlAreaPackage.CONTROL_AREA__PTOLERANCE:
				setPTolerance((ActivePower)newValue);
				return;
			case ControlAreaPackage.CONTROL_AREA__TYPE:
				setType((ControlAreaTypeKind)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ControlAreaPackage.CONTROL_AREA__NET_INTERCHANGE:
				setNetInterchange((ActivePower)null);
				return;
			case ControlAreaPackage.CONTROL_AREA__PTOLERANCE:
				setPTolerance((ActivePower)null);
				return;
			case ControlAreaPackage.CONTROL_AREA__TYPE:
				setType(TYPE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ControlAreaPackage.CONTROL_AREA__NET_INTERCHANGE:
				return netInterchange != null;
			case ControlAreaPackage.CONTROL_AREA__PTOLERANCE:
				return pTolerance != null;
			case ControlAreaPackage.CONTROL_AREA__TYPE:
				return type != TYPE_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (type: ");
		result.append(type);
		result.append(')');
		return result.toString();
	}

} //ControlAreaImpl
